<%--
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2023-06-05
  Time: 16:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script>
        if(self!=parent){
            parent.location=self.location;//防止被人嵌入
        }
    </script>
</head>
<body>
<p style="color: red;">
    <%
        String tip=(String)request.getAttribute("tip");
    %>
    <%=tip==null?"":tip%>
</p>
<%
    Object o=session.getAttribute("USER_LOGIN");
    if(o!=null){
        out.print("您已登录");
        out.print("<a href='main.jsp'>主页</a>");
        return;

    }
%>
<%
    //读取cookie中的保存的用户名
    String name="";
    Cookie []cr=request.getCookies();
    for (int i = 0; cr!=null &&i <cr.length ; i++) {
        if(cr[i].getName().equals("UNAME")){
            name=cr[i].getValue();
            break;
        }
    }
%>
  <form action="doLogin.jsp" method="post">
      <input type="text" name="name" required placeholder="用户名" value="<%=name%>"/>
      <input type="password" name="pass" required placeholder="密码"/>
      <input type="submit"  value="登录"/>

  </form>
</body>
</html>
